#include <QtGui>
#include "beptest.h"

beptest::beptest(QWidget *parent) : QWidget(parent) {
	data = new DATA();
	getdata = new GETDATA(data);
	setdata = new SETDATA(data);

	tcpServer = new QTcpServer(this);
	tcpServer->listen(QHostAddress("127.0.0.1"), 12365);
	connect(tcpServer, SIGNAL(newConnection()), this, SLOT(estConn()));

	ldefState = new QPushButton(trUtf8("Грозозащита::состояние"));
// 	ldefOff = new QPushButton(trUtf8("Грозозащита::включена"));
// 	ACOff = new QPushButton(trUtf8("Питание::включена"));
	ACU = new QLineEdit("");
	ACUl = new QLabel(trUtf8("Питание::U"));
// 	ACHz = new QLineEdit("");
// 	ACHzl = new QLabel(trUtf8("Питание::Hz"));
	KNS1Off = new QPushButton(trUtf8("КНС1::включена"));
// 	KNS1Norma = new QPushButton(trUtf8("КНС1::норма"));
	KNS1Avar = new QPushButton(trUtf8("КНС1::авария"));
	KNS1Avarseti = new QPushButton(trUtf8("КНС1::авария сети"));
	KNS1Ogran = new QPushButton(trUtf8("КНС1::ограничение"));
	KNS1Peregrev = new QPushButton(trUtf8("КНС1::перегрев"));
	KNS1Temp = new QLineEdit("");
	KNS1Templ = new QLabel(trUtf8("КНС1::Temp"));
	KNS2Off = new QPushButton(trUtf8("КНС2::включена"));
// 	KNS2Norma = new QPushButton(trUtf8("КНС2::норма"));
	KNS2Avar = new QPushButton(trUtf8("КНС2::авария"));
	KNS2Avarseti = new QPushButton(trUtf8("КНС2::авария сети"));
	KNS2Ogran = new QPushButton(trUtf8("КНС2::ограничение"));
	KNS2Peregrev = new QPushButton(trUtf8("КНС2::перегрев"));
	KNS2Temp = new QLineEdit("");
	KNS2Templ = new QLabel(trUtf8("КНС2::Temp"));
	KNS3Off = new QPushButton(trUtf8("КНС3::включена"));
// 	KNS3Norma = new QPushButton(trUtf8("КНС3::норма"));
	KNS3Avar = new QPushButton(trUtf8("КНС3::авария"));
	KNS3Avarseti = new QPushButton(trUtf8("КНС3::авария сети"));
	KNS3Ogran = new QPushButton(trUtf8("КНС3::ограничение"));
	KNS3Peregrev = new QPushButton(trUtf8("КНС3::перегрев"));
	KNS3Temp = new QLineEdit("");
	KNS3Templ = new QLabel(trUtf8("КНС3::Temp"));
	KNS4Off = new QPushButton(trUtf8("КНС4::включена"));
// 	KNS4Norma = new QPushButton(trUtf8("КНС4::норма"));
	KNS4Avar = new QPushButton(trUtf8("КНС4::авария"));
	KNS4Avarseti = new QPushButton(trUtf8("КНС4::авария сети"));
	KNS4Ogran = new QPushButton(trUtf8("КНС4::ограничение"));
	KNS4Peregrev = new QPushButton(trUtf8("КНС4::перегрев"));
	KNS4Temp = new QLineEdit("");
	KNS4Templ = new QLabel(trUtf8("КНС4::Temp"));
	AKB1Off = new QPushButton(trUtf8("АКБ1::включена"));
// 	AKB1Charging = new QPushButton(trUtf8("АКБ1::заряд"));
// 	AKB1Discharging = new QPushButton(trUtf8("АКБ1::разряд"));
// 	AKB1Fulldischarg = new QPushButton(trUtf8("АКБ1::полн разряд"));
// 	AKB1Trening = new QPushButton(trUtf8("АКБ1::авт тренинг"));
	AKB1U1 = new QLineEdit("");
	AKB1U1l = new QLabel(trUtf8("АКБ1::U1"));
	AKB1U2 = new QLineEdit("");
	AKB1U2l = new QLabel(trUtf8("АКБ1::U2"));
	AKB1U3 = new QLineEdit("");
	AKB1U3l = new QLabel(trUtf8("АКБ1::U3"));
	AKB1U4 = new QLineEdit("");
	AKB1U4l = new QLabel(trUtf8("АКБ1::U4"));
	AKB1U5 = new QLineEdit("");
	AKB1U5l = new QLabel(trUtf8("АКБ1::U5"));
	AKB1I = new QLineEdit("");
	AKB1Il = new QLabel(trUtf8("АКБ1::I"));
	AKB1Temp = new QLineEdit("");
	AKB1Templ = new QLabel(trUtf8("АКБ1::Temp"));
	AKB2Off = new QPushButton(trUtf8("АКБ2::включена"));
// 	AKB2Charging = new QPushButton(trUtf8("АКБ2::заряд"));
// 	AKB2Discharging = new QPushButton(trUtf8("АКБ2::разряд"));
// 	AKB2Fulldischarg = new QPushButton(trUtf8("АКБ2::полн разряд"));
// 	AKB2Trening = new QPushButton(trUtf8("АКБ2::авт тренинг"));
	AKB2U1 = new QLineEdit("");
	AKB2U1l = new QLabel(trUtf8("АКБ2::U1"));
	AKB2U2 = new QLineEdit("");
	AKB2U2l = new QLabel(trUtf8("АКБ2::U2"));
	AKB2U3 = new QLineEdit("");
	AKB2U3l = new QLabel(trUtf8("АКБ2::U3"));
	AKB2U4 = new QLineEdit("");
	AKB2U4l = new QLabel(trUtf8("АКБ2::U4"));
	AKB2U5 = new QLineEdit("");
	AKB2U5l = new QLabel(trUtf8("АКБ2::U5"));
	AKB2I = new QLineEdit("");
	AKB2Il = new QLabel(trUtf8("АКБ2::I"));
	AKB2Temp = new QLineEdit("");
	AKB2Templ = new QLabel(trUtf8("АКБ2::Temp"));
	LoadOff = new QPushButton(trUtf8("Нагрузка::включена"));
	LoadI = new QLineEdit("");
	LoadIl = new QLabel(trUtf8("Нагрузка::ток"));
	Load1State = new QPushButton(trUtf8("Нагрузка1::состояние"));
	Load2State = new QPushButton(trUtf8("Нагрузка2::состояние"));
	Load3State = new QPushButton(trUtf8("Нагрузка3::состояние"));
	CoolerOff = new QPushButton(trUtf8("Вентилятор::включен"));
	CoolerForcedOn = new QPushButton(trUtf8("Вентилятор::прин. включен"));
	ExitU = new QLineEdit("");
	ExitUl = new QLabel(trUtf8("Общее::Напряжение"));

	ldefState->setCheckable(true);
// 	ldefOff->setCheckable(true);
// 	ACOff->setCheckable(true);
	KNS1Off->setCheckable(true);
// 	KNS1Norma->setCheckable(true);
	KNS1Avar->setCheckable(true);
	KNS1Avarseti->setCheckable(true);
	KNS1Ogran->setCheckable(true);
	KNS1Peregrev->setCheckable(true);
	KNS2Off->setCheckable(true);
// 	KNS2Norma->setCheckable(true);
	KNS2Avar->setCheckable(true);
	KNS2Avarseti->setCheckable(true);
	KNS2Ogran->setCheckable(true);
	KNS2Peregrev->setCheckable(true);
	KNS3Off->setCheckable(true);
// 	KNS3Norma->setCheckable(true);
	KNS3Avar->setCheckable(true);
	KNS3Avarseti->setCheckable(true);
	KNS3Ogran->setCheckable(true);
	KNS3Peregrev->setCheckable(true);
	KNS4Off->setCheckable(true);
// 	KNS4Norma->setCheckable(true);
	KNS4Avar->setCheckable(true);
	KNS4Avarseti->setCheckable(true);
	KNS4Ogran->setCheckable(true);
	KNS4Peregrev->setCheckable(true);
	AKB1Off->setCheckable(true);
// 	AKB1Charging->setCheckable(true);
// 	AKB1Discharging->setCheckable(true);
// 	AKB1Fulldischarg->setCheckable(true);
// 	AKB1Trening->setCheckable(true);
	AKB2Off->setCheckable(true);
// 	AKB2Charging->setCheckable(true);
// 	AKB2Discharging->setCheckable(true);
// 	AKB2Fulldischarg->setCheckable(true);
// 	AKB2Trening->setCheckable(true);
	LoadOff->setCheckable(true);
	Load1State->setCheckable(true);
	Load2State->setCheckable(true);
	Load3State->setCheckable(true);
	CoolerOff->setCheckable(true);
	CoolerForcedOn->setCheckable(true);

	connect(ldefState, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(ldefOff, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(ACOff, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(ACU, SIGNAL(editingFinished()), this, SLOT(updateData()));
// 	connect(ACHz, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(KNS1Off, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(KNS1Norma, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS1Avar, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS1Avarseti, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS1Ogran, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS1Peregrev, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS1Temp, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(KNS2Off, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(KNS2Norma, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS2Avar, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS2Avarseti, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS2Ogran, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS2Peregrev, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS2Temp, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(KNS3Off, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(KNS3Norma, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS3Avar, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS3Avarseti, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS3Ogran, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS3Peregrev, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS3Temp, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(KNS4Off, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(KNS4Norma, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS4Avar, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS4Avarseti, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS4Ogran, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS4Peregrev, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(KNS4Temp, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB1Off, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(AKB1Charging, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(AKB1Discharging, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(AKB1Fulldischarg, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(AKB1Trening, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(AKB1U1, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB1U2, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB1U3, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB1U4, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB1U5, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB1I, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB1Temp, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB2Off, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(AKB2Charging, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(AKB2Discharging, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(AKB2Fulldischarg, SIGNAL(clicked()), this, SLOT(updateData()));
// 	connect(AKB2Trening, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(AKB2U1, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB2U2, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB2U3, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB2U4, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB2U5, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB2I, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(AKB2Temp, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(LoadOff, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(Load1State, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(Load2State, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(Load3State, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(CoolerOff, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(CoolerForcedOn, SIGNAL(clicked()), this, SLOT(updateData()));
	connect(LoadI, SIGNAL(editingFinished()), this, SLOT(updateData()));
	connect(ExitU, SIGNAL(editingFinished()), this, SLOT(updateData()));

	QGridLayout *mainLayout = new QGridLayout;
	mainLayout->addWidget(ldefState, 0, 0, 1, 2);
// 	mainLayout->addWidget(ldefOff, 1, 0, 1, 2);
// 	mainLayout->addWidget(ACOff, 2, 0, 1, 2);
	mainLayout->addWidget(ACU, 3, 1, 1, 1);
	mainLayout->addWidget(ACUl, 3, 0, 1, 1);
// 	mainLayout->addWidget(ACHz, 4, 1, 1, 1);
// 	mainLayout->addWidget(ACHzl, 4, 0, 1, 1);
	mainLayout->addWidget(KNS1Off, 5, 0, 1, 2);
// 	mainLayout->addWidget(KNS1Norma, 6, 0, 1, 2);
	mainLayout->addWidget(KNS1Avar, 7, 0, 1, 2);
	mainLayout->addWidget(KNS1Avarseti, 8, 0, 1, 2);
	mainLayout->addWidget(KNS1Ogran, 9, 0, 1, 2);
	mainLayout->addWidget(KNS1Peregrev, 10, 0, 1, 2);
	mainLayout->addWidget(KNS1Temp, 11, 1, 1, 1);
	mainLayout->addWidget(KNS1Templ, 11, 0, 1, 1);
	mainLayout->addWidget(KNS2Off, 12, 0, 1, 2);
// 	mainLayout->addWidget(KNS2Norma, 13, 0, 1, 2);
	mainLayout->addWidget(KNS2Avar, 14, 0, 1, 2);
	mainLayout->addWidget(KNS2Avarseti, 15, 0, 1, 2);
	mainLayout->addWidget(KNS2Ogran, 16, 0, 1, 2);
	mainLayout->addWidget(KNS2Peregrev, 17, 0, 1, 2);
	mainLayout->addWidget(KNS2Temp, 18, 1, 1, 1);
	mainLayout->addWidget(KNS2Templ, 18, 0, 1, 1);
	mainLayout->addWidget(KNS3Off, 0, 2, 1, 2);
// 	mainLayout->addWidget(KNS3Norma, 1, 2, 1, 2);
	mainLayout->addWidget(KNS3Avar, 2, 2, 1, 2);
	mainLayout->addWidget(KNS3Avarseti, 3, 2, 1, 2);
	mainLayout->addWidget(KNS3Ogran, 4, 2, 1, 2);
	mainLayout->addWidget(KNS3Peregrev, 5, 2, 1, 2);
	mainLayout->addWidget(KNS3Temp, 6, 3, 1, 1);
	mainLayout->addWidget(KNS3Templ, 6, 2, 1, 1);
	mainLayout->addWidget(KNS4Off, 7, 2, 1, 2);
// 	mainLayout->addWidget(KNS4Norma, 8, 2, 1, 2);
	mainLayout->addWidget(KNS4Avar, 9, 2, 1, 2);
	mainLayout->addWidget(KNS4Avarseti, 10, 2, 1, 2);
	mainLayout->addWidget(KNS4Ogran, 11, 2, 1, 2);
	mainLayout->addWidget(KNS4Peregrev, 12, 2, 1, 2);
	mainLayout->addWidget(KNS4Temp, 13, 3, 1, 1);
	mainLayout->addWidget(KNS4Templ, 13, 2, 1, 1);
	mainLayout->addWidget(AKB1Off, 14, 2, 1, 2);
// 	mainLayout->addWidget(AKB1Charging, 15, 2, 1, 2);
// 	mainLayout->addWidget(AKB1Discharging, 16, 2, 1, 2);
// 	mainLayout->addWidget(AKB1Fulldischarg, 17, 2, 1, 2);
// 	mainLayout->addWidget(AKB1Trening, 18, 2, 1, 2);
	mainLayout->addWidget(AKB1U1, 0, 5, 1, 1);
	mainLayout->addWidget(AKB1U1l, 0, 4, 1, 1);
	mainLayout->addWidget(AKB1U2, 1, 5, 1, 1);
	mainLayout->addWidget(AKB1U2l, 1, 4, 1, 1);
	mainLayout->addWidget(AKB1U3, 2, 5, 1, 1);
	mainLayout->addWidget(AKB1U3l, 2, 4, 1, 1);
	mainLayout->addWidget(AKB1U4, 3, 5, 1, 1);
	mainLayout->addWidget(AKB1U4l, 3, 4, 1, 1);
	mainLayout->addWidget(AKB1U5, 4, 5, 1, 1);
	mainLayout->addWidget(AKB1U5l, 4, 4, 1, 1);
	mainLayout->addWidget(AKB1I, 5, 5, 1, 1);
	mainLayout->addWidget(AKB1Il, 5, 4, 1, 1);
	mainLayout->addWidget(AKB1Temp, 6, 5, 1, 1);
	mainLayout->addWidget(AKB1Templ, 6, 4, 1, 1);
	mainLayout->addWidget(AKB2Off, 7, 4, 1, 2);
// 	mainLayout->addWidget(AKB2Charging, 8, 4, 1, 2);
// 	mainLayout->addWidget(AKB2Discharging, 9, 4, 1, 2);
// 	mainLayout->addWidget(AKB2Fulldischarg, 10, 4, 1, 2);
// 	mainLayout->addWidget(AKB2Trening, 11, 4, 1, 2);
	mainLayout->addWidget(AKB2U1, 12, 5, 1, 1);
	mainLayout->addWidget(AKB2U1l, 12, 4, 1, 1);
	mainLayout->addWidget(AKB2U2, 13, 5, 1, 1);
	mainLayout->addWidget(AKB2U2l, 13, 4, 1, 1);
	mainLayout->addWidget(AKB2U3, 14, 5, 1, 1);
	mainLayout->addWidget(AKB2U3l, 14, 4, 1, 1);
	mainLayout->addWidget(AKB2U4, 15, 5, 1, 1);
	mainLayout->addWidget(AKB2U4l, 15, 4, 1, 1);
	mainLayout->addWidget(AKB2U5, 16, 5, 1, 1);
	mainLayout->addWidget(AKB2U5l, 16, 4, 1, 1);
	mainLayout->addWidget(AKB2I, 17, 5, 1, 1);
	mainLayout->addWidget(AKB2Il, 17, 4, 1, 1);
	mainLayout->addWidget(AKB2Temp, 18, 5, 1, 1);
	mainLayout->addWidget(AKB2Templ, 18, 4, 1, 1);
	mainLayout->addWidget(LoadOff, 1, 6, 1, 2);
	mainLayout->addWidget(LoadI, 2, 7, 1, 1);
	mainLayout->addWidget(LoadIl, 2, 6, 1, 1);
	mainLayout->addWidget(Load1State, 3, 6, 1, 2);
	mainLayout->addWidget(Load2State, 4, 6, 1, 2);
	mainLayout->addWidget(Load3State, 5, 6, 1, 2);
	mainLayout->addWidget(CoolerOff, 6, 6, 1, 2);
	mainLayout->addWidget(CoolerForcedOn, 7, 6, 1, 2);
	mainLayout->addWidget(ExitU, 8, 7, 1, 1);
	mainLayout->addWidget(ExitUl, 8, 6, 1, 1);
	mainLayout->setMargin(0);
	mainLayout->setSpacing(0);
	setLayout(mainLayout);

	getdata->readData();
	setWidgetsState();
}

beptest::~beptest() {

}

void beptest::estConn()
{
	QTcpSocket *tmpSocket = tcpServer->nextPendingConnection();
	setdata->setSocket(tmpSocket);
	setdata->writeData();
	getdata->setSocket(tmpSocket);
	connect(tmpSocket, SIGNAL(readyRead()), this, SLOT(readData()));
}

void beptest::setWidgetsState()
{
	if (data->getLdefState()) ldefState->setChecked(true);
	else ldefState->setChecked(false);
// 	if (data->getLdefOff()) ldefOff->setChecked(true);
// 	if (data->getACOff()) ACOff->setChecked(true);
	ACU->setText(QString("%1").arg(data->getACU()));
// 	ACHz->setText(QString("%1").arg(data->getACHz()));
	if (data->getKNSOff(1)) KNS1Off->setChecked(true);
	else KNS1Off->setChecked(false);
// 	if (data->getKNSNorma(1)) KNS1Norma->setChecked(true);
	if (data->getKNSAvar(1)) KNS1Avar->setChecked(true);
	else KNS1Avar->setChecked(false);
	if (data->getKNSAvarseti(1)) KNS1Avarseti->setChecked(true);
	else KNS1Avarseti->setChecked(false);
	if (data->getKNSOgran(1)) KNS1Ogran->setChecked(true);
	else KNS1Ogran->setChecked(false);
	if (data->getKNSPeregrev(1)) KNS1Peregrev->setChecked(true);
	else KNS1Peregrev->setChecked(false);
	KNS1Temp->setText(QString("%1").arg(data->getKNSTemp(1)));
	if (data->getKNSOff(2)) KNS2Off->setChecked(true);
	else KNS2Off->setChecked(false);
// 	if (data->getKNSNorma(2)) KNS2Norma->setChecked(true);
	if (data->getKNSAvar(2)) KNS2Avar->setChecked(true);
	else KNS2Avar->setChecked(false);
	if (data->getKNSAvarseti(2)) KNS2Avarseti->setChecked(true);
	else KNS2Avarseti->setChecked(false);
	if (data->getKNSOgran(2)) KNS2Ogran->setChecked(true);
	KNS2Ogran->setChecked(false);
	if (data->getKNSPeregrev(2)) KNS2Peregrev->setChecked(true);
	else KNS2Peregrev->setChecked(false);
	KNS2Temp->setText(QString("%1").arg(data->getKNSTemp(2)));
	if (data->getKNSOff(3)) KNS3Off->setChecked(true);
	else KNS3Off->setChecked(false);
// 	if (data->getKNSNorma(3)) KNS3Norma->setChecked(true);
	if (data->getKNSAvar(3)) KNS3Avar->setChecked(true);
	else KNS3Avar->setChecked(false);
	if (data->getKNSAvarseti(3)) KNS3Avarseti->setChecked(true);
	else KNS3Avarseti->setChecked(false);
	if (data->getKNSOgran(3)) KNS3Ogran->setChecked(true);
	else KNS3Ogran->setChecked(false);
	if (data->getKNSPeregrev(3)) KNS3Peregrev->setChecked(true);
	else KNS3Peregrev->setChecked(false);
	KNS3Temp->setText(QString("%1").arg(data->getKNSTemp(3)));
	if (data->getKNSOff(4)) KNS4Off->setChecked(true);
	else KNS4Off->setChecked(false);
// 	if (data->getKNSNorma(4)) KNS4Norma->setChecked(true);
	if (data->getKNSAvar(4)) KNS4Avar->setChecked(true);
	else KNS4Avar->setChecked(false);
	if (data->getKNSAvarseti(4)) KNS4Avarseti->setChecked(true);
	else KNS4Avarseti->setChecked(false);
	if (data->getKNSOgran(4)) KNS4Ogran->setChecked(true);
	else KNS4Ogran->setChecked(false);
	if (data->getKNSPeregrev(4)) KNS4Peregrev->setChecked(true);
	else KNS4Peregrev->setChecked(false);
	KNS4Temp->setText(QString("%1").arg(data->getKNSTemp(4)));
	if (data->getAKBOff(1)) AKB1Off->setChecked(true);
	else AKB1Off->setChecked(false);
// 	if (data->getAKBCharging(1)) AKB1Charging->setChecked(true);
// 	if (data->getAKBDischarging(1)) AKB1Discharging->setChecked(true);
// 	if (data->getAKBFulldischarg(1)) AKB1Fulldischarg->setChecked(true);
// 	if (data->getAKBTrening(1)) AKB1Trening->setChecked(true);
	AKB1U1->setText(QString("%1").arg(data->getAKBU1(1)));
	AKB1U2->setText(QString("%1").arg(data->getAKBU2(1)));
	AKB1U3->setText(QString("%1").arg(data->getAKBU3(1)));
	AKB1U4->setText(QString("%1").arg(data->getAKBU4(1)));
	AKB1U5->setText(QString("%1").arg(data->getAKBU5(1)));
	AKB1I->setText(QString("%1").arg(data->getAKBI(1)));
	AKB1Temp->setText(QString("%1").arg(data->getAKBTemp(1)));
	if (data->getAKBOff(2)) AKB2Off->setChecked(true);
	else AKB2Off->setChecked(false);
// 	if (data->getAKBCharging(2)) AKB2Charging->setChecked(true);
// 	if (data->getAKBDischarging(2)) AKB2Discharging->setChecked(true);
// 	if (data->getAKBFulldischarg(2)) AKB2Fulldischarg->setChecked(true);
// 	if (data->getAKBTrening(2)) AKB2Trening->setChecked(true);
	AKB2U1->setText(QString("%1").arg(data->getAKBU1(2)));
	AKB2U2->setText(QString("%1").arg(data->getAKBU2(2)));
	AKB2U3->setText(QString("%1").arg(data->getAKBU3(2)));
	AKB2U4->setText(QString("%1").arg(data->getAKBU4(2)));
	AKB2U5->setText(QString("%1").arg(data->getAKBU5(2)));
	AKB2I->setText(QString("%1").arg(data->getAKBI(2)));
	AKB2Temp->setText(QString("%1").arg(data->getAKBTemp(2)));
	if (data->getLoadOff()) LoadOff->setChecked(true);
	else LoadOff->setChecked(false);
	LoadI->setText(QString("%1").arg(data->getLoadI()));
	if (data->getLoad1State()) Load1State->setChecked(true);
	else Load1State->setChecked(false);
	if (data->getLoad2State()) Load2State->setChecked(true);
	else Load2State->setChecked(false);
	if (data->getLoad3State()) Load3State->setChecked(true);
	else Load3State->setChecked(false);
	if (data->getCoolerOff()) CoolerOff->setChecked(true);
	else CoolerOff->setChecked(false);
	if (data->getCoolerForcedOn()) CoolerForcedOn->setChecked(true);
	else CoolerForcedOn->setChecked(false);
	ExitU->setText(QString("%1").arg(data->getExitU()));
}

void beptest::updateData()
{
	if (ldefState->isChecked()) data->setLdefState(true);
	else data->setLdefState(false);
// 	if (ldefOff->isChecked()) data->setLdefOff(true);
// 	else data->setLdefOff(false);
// 	if (ACOff->isChecked()) data->setACOff(true);
// 	else data->setACOff(false);
	data->setACU(ACU->text().toFloat());
// 	data->setACHz(ACHz->text().toFloat());

	if (KNS1Off->isChecked()) data->setKNSOff(1, true);
	else data->setKNSOff(1, false);
// 	if (KNS1Norma->isChecked()) data->setKNSNorma(1, true);
// 	else data->setKNSNorma(1, false);
	if (KNS1Avar->isChecked()) data->setKNSAvar(1, true);
	else data->setKNSAvar(1, false);
	if (KNS1Avarseti->isChecked()) data->setKNSAvarseti(1, true);
	else data->setKNSAvarseti(1, false);
	if (KNS1Ogran->isChecked()) data->setKNSOgran(1, true);
	else data->setKNSOgran(1, false);
	if (KNS1Peregrev->isChecked()) data->setKNSPeregrev(1, true);
	else data->setKNSPeregrev(1, false);
	data->setKNSTemp(1, KNS1Temp->text().toFloat());

	if (KNS2Off->isChecked()) data->setKNSOff(2, true);
	else data->setKNSOff(2, false);
// 	if (KNS2Norma->isChecked()) data->setKNSNorma(2, true);
// 	else data->setKNSNorma(2, false);
	if (KNS2Avar->isChecked()) data->setKNSAvar(2, true);
	else data->setKNSAvar(2, false);
	if (KNS2Avarseti->isChecked()) data->setKNSAvarseti(2, true);
	else data->setKNSAvarseti(2, false);
	if (KNS2Ogran->isChecked()) data->setKNSOgran(2, true);
	else data->setKNSOgran(2, false);
	if (KNS2Peregrev->isChecked()) data->setKNSPeregrev(2, true);
	else data->setKNSPeregrev(2, false);
	data->setKNSTemp(2, KNS1Temp->text().toFloat());

	if (KNS3Off->isChecked()) data->setKNSOff(3, true);
	else data->setKNSOff(3, false);
// 	if (KNS3Norma->isChecked()) data->setKNSNorma(3, true);
// 	else data->setKNSNorma(3, false);
	if (KNS3Avar->isChecked()) data->setKNSAvar(3, true);
	else data->setKNSAvar(3, false);
	if (KNS3Avarseti->isChecked()) data->setKNSAvarseti(3, true);
	else data->setKNSAvarseti(3, false);
	if (KNS3Ogran->isChecked()) data->setKNSOgran(3, true);
	else data->setKNSOgran(3, false);
	if (KNS3Peregrev->isChecked()) data->setKNSPeregrev(3, true);
	else data->setKNSPeregrev(3, false);
	data->setKNSTemp(3, KNS1Temp->text().toFloat());

	if (KNS4Off->isChecked()) data->setKNSOff(4, true);
	else data->setKNSOff(4, false);
// 	if (KNS4Norma->isChecked()) data->setKNSNorma(4, true);
// 	else data->setKNSNorma(4, false);
	if (KNS4Avar->isChecked()) data->setKNSAvar(4, true);
	else data->setKNSAvar(4, false);
	if (KNS4Avarseti->isChecked()) data->setKNSAvarseti(4, true);
	else data->setKNSAvarseti(4, false);
	if (KNS4Ogran->isChecked()) data->setKNSOgran(4, true);
	else data->setKNSOgran(4, false);
	if (KNS4Peregrev->isChecked()) data->setKNSPeregrev(4, true);
	else data->setKNSPeregrev(4, false);
	data->setKNSTemp(4, KNS1Temp->text().toFloat());

	if (AKB1Off->isChecked()) data->setAKBOff(1, true);
	else data->setAKBOff(1, false);
// 	if (AKB1Charging->isChecked()) data->setAKBCharging(1, true);
// 	else data->setAKBCharging(1, false);
// 	if (AKB1Discharging->isChecked()) data->setAKBDischarging(1, true);
// 	else data->setAKBDischarging(1, false);
// 	if (AKB1Fulldischarg->isChecked()) data->setAKBFulldischarg(1, true);
// 	else data->setAKBFulldischarg(1, false);
// 	if (AKB1Trening->isChecked()) data->setAKBTrening(1, true);
// 	else data->setAKBTrening(1, false);
	data->setAKBU1(1, AKB1U1->text().toFloat());
	data->setAKBU2(1, AKB1U2->text().toFloat());
	data->setAKBU3(1, AKB1U3->text().toFloat());
	data->setAKBU4(1, AKB1U4->text().toFloat());
	data->setAKBU5(1, AKB1U5->text().toFloat());
	data->setAKBI(1, AKB1I->text().toFloat());
	data->setAKBTemp(1, AKB1Temp->text().toFloat());

	if (AKB2Off->isChecked()) data->setAKBOff(2, true);
	else data->setAKBOff(2, false);
// 	if (AKB2Charging->isChecked()) data->setAKBCharging(2, true);
// 	else data->setAKBCharging(2, false);
// 	if (AKB2Discharging->isChecked()) data->setAKBDischarging(2, true);
// 	else data->setAKBDischarging(2, false);
// 	if (AKB2Fulldischarg->isChecked()) data->setAKBFulldischarg(2, true);
// 	else data->setAKBFulldischarg(2, false);
// 	if (AKB2Trening->isChecked()) data->setAKBTrening(2, true);
// 	else data->setAKBTrening(2, false);
	data->setAKBU1(2, AKB2U1->text().toFloat());
	data->setAKBU2(2, AKB2U2->text().toFloat());
	data->setAKBU3(2, AKB2U3->text().toFloat());
	data->setAKBU4(2, AKB2U4->text().toFloat());
	data->setAKBU5(2, AKB2U5->text().toFloat());
	data->setAKBI(2, AKB2I->text().toFloat());
	data->setAKBTemp(2, AKB2Temp->text().toFloat());

	if (LoadOff->isChecked()) data->setLoadOff(true);
	else data->setLoadOff(false);
	data->setLoadI(LoadI->text().toFloat());
	if (Load1State->isChecked()) data->setLoad1State(true);
	else data->setLoad1State(false);
	if (Load2State->isChecked()) data->setLoad2State(true);
	else data->setLoad2State(false);
	if (Load3State->isChecked()) data->setLoad3State(true);
	else data->setLoad3State(false);
	if (CoolerOff->isChecked()) data->setCoolerOff(true);
	else data->setCoolerOff(false);
	if (CoolerForcedOn->isChecked()) data->setCoolerForcedOn(true);
	else data->setCoolerForcedOn(false);
	data->setExitU(ExitU->text().toFloat());

	setdata->writeData();
}

void beptest::readData() {
	getdata->readData();
	setWidgetsState();
}
